package com.vishnu.main;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import com.vishnu.pojo.Grade;
import com.vishnu.pojo.Student;

public class PracticeOnOneToOne {
    public static void main(String[] args) {
		Configuration cfg =new Configuration();
		cfg.configure("hib.cfg.xml");
		SessionFactory sf=cfg.buildSessionFactory();
		Session hsession=sf.openSession();
		Transaction tx=hsession.beginTransaction();
	System.out.println("---------transaction started--------");

	Student student=new Student();
	student.setStudentId(1);
	student.setName("vishnu");
 
	
	Grade grade=new Grade();
	grade.setStdId(1);
	grade.setGradeName("A");
	//grade.setStdnt(student);
	
	
	hsession.save(student);
	hsession.save(grade);
	
	
	
	tx.commit();
	hsession.close();
	sf.close();
}
}
